package jdkconcurrent;

import sun.misc.Unsafe;

import java.util.concurrent.atomic.*;

/**
 * @author wcj
 * @Date 2021/8/10 10:19
 * @Version 1.0
 */
public class Test1 {

    /**
     * java中的线程分为守护线程和非守护线程，只有当所有的非守护线程都退出，虚拟机才会推出。而守护线程是不会印象到JVM的退出的
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("main enter!");
        Thread t = new Thread() {
            @Override
            public void run() {
                while (true) {
                    try {
                        System.out.println("thread is execute!");
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        t.setDaemon(true);
        t.start();
        System.out.println("main exit!");
    }
}
